﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Kelper.Domain.Models;
using Kelper.Domain.Data.Abstract;

namespace Kelper.Controllers
{
    public class IngredientController : BaseController
    {
        private IIngredientRepository repository;

        public IngredientController(IIngredientRepository repo)
        {
            repository = repo;
        }

        public new ActionResult View(string name)
        {
            Ingredient ingredient = repository.Ingredients.FirstOrDefault(i => i.Name == name);

            if (ingredient == null)
                return HttpNotFound();

            return View(ingredient);
        }
    }
}
